package Java.BlackHorse.IO;

import java.io.FileOutputStream;
import java.io.IOException;

public class IODemo3 {
    /*
    * 1.换行
    * Windows：/r/n
    * Linux:   /n
    * Mac:     /r
    * 2.续写
    * 创建对象时第二个参数默认为false，改为true则不会覆盖原来文件中的内容
    * */
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("IO\\a.txt",true);
        String str1 = "abcdrfg";
        byte[] bytes1 = str1.getBytes();
        fos.write(bytes1);


        String str2 = "\r\n";
        byte[] bytes2 = str2.getBytes();
        fos.write(bytes2);

        String str3 = "hijk";
        byte[] bytes3 = str3.getBytes();
        fos.write(bytes3);

        fos.close();
    }
}
